//
// CTCPListener.h
//

#ifndef __H_CTCPListener__
#define __H_CTCPListener__

#include "CMsgStation.h"

// The first socket for video, the second for audio
#define MAX_COUNT	2

class CTCPListener : public CMsgStation
{
protected:
	SOCKET		mListener;
	SOCKET		mAccepted[MAX_COUNT];

	WORD		mListenPort;
	BOOL		mIsListening;   // Listening thread active flag
	HANDLE		mLsnThread;

public:
	CTCPListener();
	virtual ~CTCPListener();

public:
	void SetListenPort(WORD inPort); // For listening to TCP connect request
	WORD GetListenPort(void);

	BOOL Create(void);
	void DeleteListener(void);
	void DeleteAccepted(void);

	BOOL StartListening(void);
	void StopListening(void);
	SOCKET GetAccepted(int index = 0);
	BOOL IsSocketReady(void);

private:
	BOOL Accept(void);
	static DWORD WINAPI ListeningThrd(void *pParam);
};

#endif // __H_CTCPListener__